﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using iTelluro.Explorer.Application.MainBoundContext.DTO;
using Microsoft.Practices.Unity;
using log4net;
using System.Reflection;
using iTelluro.Explorer.Application.MainBoundContext;
using iTelluro.Explorer.Domain.Seedwork;
using iTelluro.Explorer.meteorological.Service.InstanceProviders;


namespace iTelluro.Explorer.Services
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“meteorologicalServices”。
    // 注意: 为了启动 WCF 测试客户端以测试此服务，请在解决方案资源管理器中选择 meteorologicalServices.svc 或 meteorologicalServices.svc.cs，然后开始调试。
   [UnityInstanceProviderServiceBehavior]
    public class meteorologicalServices : ImeteorologicalService
    {
       
             #region Metalert

        /// <summary>
        /// 属性注入MetalertApp
        /// </summary>
            [Dependency]
        public ImeteorologicalAppService _MetalertApp { get; set; }

        /// <summary>
        /// 新增一条Metalert记录
        /// </summary>
        /// <param name="MetalertDTO">Metalert实体</param>
        /// <returns>是否新增成功</returns>
        public bool MetalertAdd(MetalertDTO MetalertDTO)
        {
            try
            {
                return _MetalertApp.Add(MetalertDTO);
            }
            catch (Exception ex)
            {
                ILog log = LogManager.GetLogger("meteorologicalSerice-" + this.GetType().Name + "-" + MethodBase.GetCurrentMethod().Name);
                log.Error(ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 根据主键删除一条Metalert记录
        /// </summary>
        /// <param name="guid">主键值</param>
        /// <returns>是否删除成功</returns>
        public bool MetalertDelete(string guid)
        {
            try
            {
                return _MetalertApp.Remove(guid);
            }
            catch (Exception ex)
            {
                ILog log = LogManager.GetLogger("meteorologicalSerice-" + this.GetType().Name + "-" + MethodBase.GetCurrentMethod().Name);
                log.Error(ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 更新一条Metalert记录
        /// </summary>
        /// <param name="MetalertDTO">Metalert实体</param>
        /// <returns>是否更新成功</returns>
        public bool MetalertUpdate(MetalertDTO MetalertDTO)
        {
            try
            {
                return _MetalertApp.Update(MetalertDTO);
            }
            catch (Exception ex)
            {
                ILog log = LogManager.GetLogger("meteorologicalSerice-" + this.GetType().Name + "-" + MethodBase.GetCurrentMethod().Name);
                log.Error(ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 根据主键查询一条Metalert记录
        /// </summary>
        /// <param name="guid">主键值</param>
        /// <returns>查询的实体结果</returns>
        public MetalertDTO MetalertQueryById(string guid)
        {
            try
            {
                return _MetalertApp.Get(guid);
            }
            catch (Exception ex)
            {
                ILog log = LogManager.GetLogger("meteorologicalSerice-" + this.GetType().Name + "-" + MethodBase.GetCurrentMethod().Name);
                log.Error(ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 查询所有的Metalert记录
        /// </summary>
        /// <returns>所有的Metalert结果集</returns>
        public List<MetalertDTO> MetalertQueryAll()
        {
            try
            {
                return _MetalertApp.GetAll();
            }
            catch (Exception ex)
            {
                ILog log = LogManager.GetLogger("meteorologicalSerice-" + this.GetType().Name + "-" + MethodBase.GetCurrentMethod().Name);
                log.Error(ex.Message);
                return null;
            }
        }

        #endregion

    }
    }

